<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Каталог сайтов</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content=""/>
<meta name="author" content=""/>
<!-- Le styles -->
<link href="css/bootstrap.css" rel="stylesheet"/>
<style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
      h1{
            font-size:2em;
        }
    h2{
        font-size:1.5em;
    }
      .sidebar-nav {
        padding: 9px 0;
      }
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet"/>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
<!-- Fav and touch icons -->
<link rel="shortcut icon" href="../assets/ico/favicon.ico"/>
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png"/>
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png"/>
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png"/>
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png"/>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
	<div class="navbar-inner">
		<div class="container-fluid">
			<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			</a>
			<a class="brand" href="index.php">Каталог сайтов</a>
			<div class="nav-collapse collapse">
				<p class="navbar-text pull-right">
					 Вы вошли как <a href="#" class="navbar-link">Username</a>
				</p>
				<ul class="nav">
					<li class="active"><a href="index.php">Главная</a></li>
					<li><a href="#about">О нас</a></li>
					<li><a href="#contact">Контакты</a></li>
				</ul>
			</div>
			<!--/.nav-collapse -->
		</div>
	</div>
</div>
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span3">
			<div class="well sidebar-nav">
				<ul class="nav nav-list">
					<li class="nav-header">Разделы каталога:</li>
					<li><a href="index.php">Все категории</a></li>
					<?php foreach($menu as $category):?>
					<li><a href="index.php?cat=<?=$category['id_category']?>"><?=$category['name']?>
					</a></li>
					<?php endforeach?>
				</ul>
			</div>
			<!--/.well -->
		</div>
		<!--/span-->
		<div class="span9">
			<div class="hero-unit">
				<?php if(isset($_GET['cat']) && !array_key_exists($_GET['cat'], $menu)):?>
				<div class="alert alert-block">
					<h4>Пардон!</h4>
					 Такая категория отсутствует...<br/><br/>
					попробуйте начать с <a href="index.php">главной страницы</a>
				</div>
				<?php elseif(empty($data)):?>
				<div class="alert alert-info">
					<p>
						Пардоньте, в категории пока нету сайтов. Попробуйте зайти позже.
					</p>
				</div>
            </div>
                <div class="row-fluid">
    				<p align="right">
    					<a class="btn" href="index.php?add">
    					<i class="icon-plus"></i> Добавить сайт</a>
    				</p>
                </div>
				<?php elseif($data[0]['name'] == null):?>
				<h1>Все категории</h1>
			</div>
			<div class="row-fluid">
				<p align="right">
					<a class="btn" href="index.php?add">
					<i class="icon-plus"></i> Добавить сайт</a>
				</p>
			</div>
				<?php 
                    $counter = 0;
                    $rows = array();
                    foreach($data as $site) {
                        $rows[] = $site;
                        $counter++;
                        
                        if ($counter == 3) {
                            # echo sub_tpl
                             include '_img3.php';
                             
                            $counter = 0;
                            $rows = array();
                        }
                        
                    }
                    if (count($rows) > 0 )
                        include '_img3.php';
                    ?>
				
				<!--/span-->
				
				<?php else:?>
				<h1><?=$data[0]['name']?>(<?=$num_of_sites?>)</h1>
			</div>
			<div class="row-fluid">
				<p align="right">
					<a class="btn" href="index.php?add">
					<i class="icon-plus"></i> Добавить сайт</a>
				</p>
			</div>
			<?php 
                    $counter = 0;
                    $rows = array();
                    foreach($data as $site) {
                        $rows[] = $site;
                        $counter++;
                        
                        if ($counter == 3) {
                            # echo sub_tpl
                             include '_img3.php';
                             
                            $counter = 0;
                            $rows = array();
                        }
                        
                    }
                    if (count($rows) > 0 )
                        include '_img3.php';
                    ?>
				<?php endif?>
			</div>
			<!--/row-->		
	<hr/>
	<footer>
	<p>
		&copy; Company 2012
	</p>
	</footer>
</div>
<!--/.fluid-container-->
<!-- Le javascript
    ================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="../assets/js/bootstrap-alert.js"></script>
<script src="../assets/js/bootstrap-modal.js"></script>
<script src="../assets/js/bootstrap-dropdown.js"></script>
<script src="../assets/js/bootstrap-scrollspy.js"></script>
<script src="../assets/js/bootstrap-tab.js"></script>
<script src="../assets/js/bootstrap-tooltip.js"></script>
<script src="../assets/js/bootstrap-popover.js"></script>
<script src="../assets/js/bootstrap-button.js"></script>
<script src="../assets/js/bootstrap-collapse.js"></script>
<script src="../assets/js/bootstrap-carousel.js"></script>
<script src="../assets/js/bootstrap-typeahead.js"></script>
</body>
</html>